import { defineStore } from "pinia";
import { ref } from "vue";
import { ElMessage } from "element-plus";

export const useListStore = defineStore("appList", () => {
  // 办公教学
  const bgjxList = ref([
    { id: 1, icons: "/public/images/icon.png", title: "备课教案" },
    { id: 2, icons: "/public/images/icon.png", title: "课表" },
    { id: 3, icons: "/public/images/icon.png", title: "文件" },
    { id: 4, icons: "/public/images/icon.png", title: "课程" },
    { id: 5, icons: "/public/images/icon.png", title: "云盘" },
    { id: 6, icons: "/public/images/icon.png", title: "活跃课程" },
    { id: 7, icons: "/public/images/icon.png", title: "请假" },
    { id: 8, icons: "/public/images/icon.png", title: "销假" },
    { id: 9, icons: "/public/images/icon.png", title: "加班" },
  ]);

  // 教学监控
  const jxjkList = ref([
    { id: 1, icons: "/public/images/icon.png", title: "开课" },
    { id: 2, icons: "/public/images/icon.png", title: "评课" },
    { id: 3, icons: "/public/images/icon.png", title: "听评数据" },
    { id: 4, icons: "/public/images/icon.png", title: "课堂教学" },
  ]);

  // 教学数据分析
  const jxsjfxList = ref([
    { id: 1, icons: "/public/images/icon.png", title: "管理听课监督" },
    { id: 2, icons: "/public/images/icon.png", title: "课程统计" },
    { id: 3, icons: "/public/images/icon.png", title: "成绩统计" },
    { id: 4, icons: "/public/images/icon.png", title: "学习统计" },
  ]);

  // 学生评价
  const xspjList = ref([
    { id: 1, icons: "/public/images/icon.png", title: "课程评价" },
    { id: 2, icons: "/public/images/icon.png", title: "教学评价" },
    { id: 3, icons: "/public/images/icon.png", title: "学生评价" },
    { id: 4, icons: "/public/images/icon.png", title: "学生满意度" },
  ]);

  // 搜索
  const searchList = (value) => {
    const bgjx = bgjxList.value.filter((item) => item.title.includes(value));
    const jxjk = jxjkList.value.filter((item) => item.title.includes(value));
    const jxsjfx = jxsjfxList.value.filter((item) =>
      item.title.includes(value)
    );
    const xspj = xspjList.value.filter((item) => item.title.includes(value));
    if (bgjx == "" && jxjk == "" && jxsjfx == "" && xspj == "") {
      ElMessage({
        showClose: true,
        message: "没有找到相关的内容",
        type: "error",
      });
    } else {
      bgjxList.value = bgjx;
      jxjkList.value = jxjk;
      jxsjfxList.value = jxsjfx;
      xspjList.value = xspj;
    }
  };

  return {
    bgjxList,
    jxjkList,
    jxsjfxList,
    xspjList,
    searchList,
  };
});
